<template>
	<!-- 我的-康复顾问-会员管理 -->
	<view class="content">
		<view class="bg"></view>
		<!-- 会员列表 -->
		<view style="z-index: 100;margin-top: 20rpx;">
			<view class="item" style="justify-content: space-between;">
				<view style="display: flex; align-items: center;">
					<view class="left">姓名</view>
					<view class="right">{{data.memberName}}</view>
				</view>
				<view style="display: flex; align-items: center;margin-top: 20rpx;">
					<view class="left">训练部位</view>
					<view class="right">{{ this.getSymptomText(data.symptom) }}</view>
				</view>
				<view style="display: flex; align-items: center;margin-top: 20rpx;">
					<view class="left">训练时间</view>
					<view class="right"> {{ formattedDate(data.recureLesson.lessonDate) }} {{data.recureLesson.lessonHourTime}}</view>
				</view>
			</view>
		</view>
		<view style="z-index: 100;margin-bottom: 60rpx;">
			<view class="item" style="justify-content: space-between;">
				<view class="title">上传训练信息</view>
				<view class="example-body">
					<uni-file-picker limit="1" title="图片"></uni-file-picker>
				</view>
				<view class="example-body">
					<uni-file-picker limit="1" title="视频"></uni-file-picker>
				</view>
				<view class="sub_title">备注</view>
				<textarea placeholder="请输入备注信息" v-model="data.des" placeholder-style="color:#D8D8D8;margin-left:40rpx;margin-top:20rpx;"></textarea>
			</view>
		</view>
		<view class="footer">
			<view class="cancel" @click="handleCancel">
				<text class="cancel-text">取消</text>
			</view>
			<view class="submit" @click="handleSubmit">
				<text class="submit-text">提交</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: {},
				trainId: 0,
			}
		},
		onLoad(option) {
			this.trainId = option.id;
			this.getTrainDetail(option.id);
		},
		methods: {
			handleSubmit() {
				// 处理提交逻辑
				let that = this;
				uni.request({
					url: "https://guokang365.mordo-care.com/api/recureTrain/update/" + that.trainId,
					method: 'POST',
					data: that.data,
					//仅为示例，并非真实接口地址。
					header: {
						'Cookie': "JSESSIONID=" + getApp().globalData.serverSession
						// 'JSESSIONID': getApp().globalData.serverSession //自定义请求头信息
					},
					success: (res) => {
						// that.baseFormData.lessonDate = that.formattedDate(data.lessonDate);
						// todo 需要使用级联查询，查套餐名
						if (res.data.result != '100') {
							uni.showModal({
								content: '更新失败',
								showCancel: false,
								buttonText: '确定',
							})
				
						} else {
							uni.showModal({
								content: '更新成功',
								showCancel: false,
								buttonText: '确定',
							})
							// that.getClassDetail(that.id);
						}
					},
				});
			},
			handleCancel() {
				// 处理取消逻辑
			},
			getTrainDetail(id) {
				let that = this;
				uni.request({
					url: "https://guokang365.mordo-care.com/api/recureTrain/findCascade/" + id,
					method: 'POST',
					//仅为示例，并非真实接口地址。
					header: {
						'Cookie': "JSESSIONID=" + getApp().globalData.serverSession
						// 'JSESSIONID': getApp().globalData.serverSession //自定义请求头信息
					},
					data: {
						"cascades": [{
							"column": "recureLesson",
						},{
							"column": "recureTrainPhotoList",
						},{
							"column": "recureTrainVideoList",
						}],
					},
					success: (res) => {
						// todo 需要使用级联查询，查套餐名
						if (res.data.result != '100') {
							// 获取会员详情失败，不确定是否要弹窗
						} else {
							that.data = res.data.entity;
						}
					},
				});
			},
			getSymptomText(value) {
				switch (value) {
					case 1:
						return '全髋'
					case 2:
						return '全膝'
					case 3:
						return '全肩'
					case 4:
						return '全肘'
					case 5:
						return '掌指'
					case 6:
						return '髋部'
					default:
						return ''
				}
			},
			formattedDate(dateString) {
				const year = dateString.substr(0, 4);
				const month = dateString.substr(4, 2);
				const day = dateString.substr(6, 2);
				const date = new Date(year, month - 1, day); // 注意月份要减一
				const formattedDate = `${date.getFullYear()}-${date.getMonth()+1}-${date.getDate()}`; // 格式化日期字符串
				return formattedDate;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.search {
		width: 750rpx;
		height: 128rpx;
		z-index: 1000;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 0 22rpx 0 10rpx;
		box-sizing: border-box;

	}

	.bg {
		width: 750rpx;
		height: 128rpx;
		background: #CBFFDB;
		filter: blur(25px);
		position: absolute;
		z-index: 1;
		top: 0px;
	}

	.add-btn {
		width: 100rpx;
		height: 66rpx;

	}

	.item {
		background: #FFFFFF;
		border-radius: 22rpx;
		box-shadow: 0rpx 11rpx 14rpx 0rpx #E9F7ED;
		display: flex;
		width: 707rpx;
		box-sizing: border-box;
		padding: 32rpx;
		flex-direction: column;
		z-index: 1000;
		margin-bottom: 30rpx;

		.content-top {
			display: flex;
			justify-content: space-between;
			border-bottom: 1rpx solid #E1E1E1;
			padding-bottom: 30rpx;

			.img {
				border-radius: 50%;
				width: 74rpx;
				height: 74rpx;
				margin-right: 23rpx;
			}

			.name {
				font-size: 36rpx;
				font-family: PingFangSC-Semibold, PingFang SC;
				font-weight: 600;
				color: #48AF4E;
				line-height: 51rpx;
			}

			.phone {
				height: 36rpx;
				font-size: 25rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #464646;
				line-height: 36rpx;
			}

		}

		.left {
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #393939;
			// text-align: center;
			margin-top: 6rpx;
			flex-grow: 1;
			margin-left: 10rpx;
		}

		.right {
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #393939;
			text-align: center;
			margin-top: 6rpx;
			flex-grow: 0;
			margin-right: 10rpx;
		}

		.go-icon {
			width: 17rpx;
			height: 25rpx;
			margin-top: 10rpx;
		}

		.hysz-icon {
			width: 36rpx;
			height: 36rpx;
			margin-right: 12rpx;
		}

		.title {
			font-size: 30rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: bold;
			color: #393939;
			margin-left: 10rpx;
		}

		.sub_title {
			// font-size: 28rpx;
			// font-family: PingFangSC-Medium, PingFang SC;
			// font-weight: bold;
			// color: #393939;
			margin-left: 10rpx;
			margin-top: 40rpx;
			font-size: 14px;
			color: #333;
		}

		.pic {
			margin-top: 20rpx;
			margin-left: 10rpx;
			width: 120px;
			height: 120px;
			background-image: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngc8d1d6e35f62940a8f2a5ff510d4595f14ded3b06f028a7609b96eb1df570139);
			background-size: 100%;
			border-radius: 20rpx;
			border: 1px solid #dcdcdc;
		}
	}

	textarea {
		margin-top: 20rpx;
		width: 620rpx;
		height: 200rpx;
		border-radius: 20rpx;
		border: 1px solid #dcdcdc;
		margin-left: 10rpx;
		box-shadow: 0rpx 11rpx 14rpx 0rpx #E9F7ED;
		margin-bottom: 30rpx;
	}

	.example-body {
		// padding: 10px;
		margin-top: 20rpx;
		margin-left: 10rpx;
		padding-top: 0;
	}

	.footer {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 750rpx;
		height: 120rpx;
		bottom: 0rpx;
		// padding: 0 16px;
		background-color: #f5f5f5;
		position: fixed;
		z-index: 1000;
	}

	.submit,
	.cancel {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 50%;
		height: 100%;
		// border-radius: 4px;
		cursor: pointer;
	}

	.submit {
		background-color: #42AE49;
		color: #FFFFFF;
	}

	.cancel {
		background-color: #D1D1D1;
		color: #525252;
	}

	.submit-text,
	.cancel-text {
		font-size: 16px;
	}
</style>